<?php

/* Stop the theme from killing WordPress if BuddyPress is not enabled. */
if ( !class_exists( 'BP_Core_User' ) )
	return false;

define('BP_DTHEME_DISABLE_CUSTOM_HEADER', true );


function arit_remove_buddypress_admin_bar_install() {}
function arit_remove_buddypress_admin_bar_init() {
if ( function_exists('bp_core_admin_bar') ) remove_action( 'wp_footer', 'bp_core_admin_bar', 8 );
if ( function_exists('bp_core_admin_bar_css') ) {
remove_action( 'wp_head', 'bp_core_admin_bar_css', 1 ); }
if ( function_exists('bp_core_add_admin_css') ) remove_action( 'admin_menu', 'bp_core_add_admin_css' ); }
function arit_remove_buddypress_admin_bar_uninstall() {}


register_activation_hook( __FILE__, 'arit_remove_buddypress_admin_bar_install' );
add_action( 'init', 'arit_remove_buddypress_admin_bar_init' );
register_deactivation_hook( __FILE__, 'arit_remove_buddypress_admin_bar_uninstall' );

if ( function_exists( 'add_theme_support' ) )
add_theme_support( 'post-thumbnails' );


function wp_limit_post($max_char, $more_link_text = '[...]',$notagp 
= false, $stripteaser = 0, $more_file = '') {
    $content = get_the_content($more_link_text, $stripteaser, 
$more_file);
    $content = apply_filters('the_content', $content);
    $content = str_replace(']]>', ']]&gt;', $content);
    $content = strip_tags($content);
 
   if (strlen($_GET['p']) > 0) {
      if($notagp) {
      echo substr($content,0,$max_char);
      }
      else {
      echo '<p>';
      echo substr($content,0,$max_char);
      echo "</p>";
      }
   }
   else if ((strlen($content)>$max_char) && ($espacio = strpos
($content, " ", $max_char ))) {
        $content = substr($content, 0, $espacio);
        $content = $content;
        if($notagp) {
        echo substr($content,0,$max_char);
        echo $more_link_text;
        }
        else {
        echo '<p>';
        echo substr($content,0,$max_char);
        echo $more_link_text;
        echo "</p>";
        }
   }
   else {
      if($notagp) {
      echo substr($content,0,$max_char);
      }
      else {
      echo '<p>';
      echo substr($content,0,$max_char);
      echo "</p>";
      }
   }
}
